<template>
  <navbar title="新闻资讯" :isBack="true"></navbar>
  <view class="content">
    <!-- <loading v-if="!info.list.length"></loading> -->
    <picture
      v-if="!info.list.length"
      title="暂无成绩"
      imgPath="/static/image/18.png"
      imgHeight="200rpx"
      imgWidth="360rpx"
      bg="#fff"
      :height="tools.clientTopHight(50)"
    ></picture>
    <list v-else :border="true" :list="info.list"></list>
  </view>
</template>

<script setup lang="ts">
import { reactive } from 'vue'
import { onLoad, onReachBottom } from '@dcloudio/uni-app'
import { getNewsList } from '@/service/api/index'
import tools from '@/utils/tools'
import list from '@/common/list/news.vue'

let info = reactive({
  isFirst: true,
  list: [],
  page: 1
})

// 新闻资讯列表
const getNewsListApi = async () => {
  const { msg } = await getNewsList({ page: info.page })
  info.isFirst = false
  if (!msg.data.length && info.page != 1) {
    return tools.showToast('暂无更多数据'), info.page--
  }
  info.list = [...info.list, ...msg.data]
}

onReachBottom(() => {
  info.page++
  // 新闻资讯列表
  getNewsListApi()
})

onLoad(() => {
  // 新闻资讯列表
  getNewsListApi()
})
</script>

<style lang="scss" scoped>
.content {
  margin: 0 24rpx;
}
</style>
